3.73 \(\int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx\)

Optimal. Leaf size=99 \[ \frac {\left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d f \left (c^2+d^2\right )}-\frac {(B c-d (A-C)) \log (\cos (e+f x))}{f \left (c^2+d^2\right )}+\frac {x (A c+B d-c C)}{c^2+d^2} \]

[Out]

(A*c+B*d-C*c)*x/(c^2+d^2)-(B*c-(A-C)*d)*ln(cos(f*x+e))/(c^2+d^2)/f+(A*d^2-B*c*d+C*c^2)*ln(c+d*tan(f*x+e))/d/(c
^2+d^2)/f

________________________________________________________________________________________

Rubi [A]  time = 0.10, antiderivative size = 99, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 33, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.121, Rules used = {3626, 3617, 31, 3475} \[ \frac {\left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d f \left (c^2+d^2\right )}-\frac {(B c-d (A-C)) \log (\cos (e+f x))}{f \left (c^2+d^2\right )}+\frac {x (A c+B d-c C)}{c^2+d^2} \]

Antiderivative was successfully verified.

[In]

Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x]),x]

[Out]

((A*c - c*C + B*d)*x)/(c^2 + d^2) - ((B*c - (A - C)*d)*Log[Cos[e + f*x]])/((c^2 + d^2)*f) + ((c^2*C - B*c*d +
A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)*f)

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3617

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[
A/(b*f), Subst[Int[(a + x)^m, x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]

Rule 3626

Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/((a_.) + (b_.)*tan[(e_.) + (f_.)*
(x_)]), x_Symbol] :> Simp[((a*A + b*B - a*C)*x)/(a^2 + b^2), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2), I
nt[(1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Dist[(A*b - a*B - b*C)/(a^2 + b^2), Int[Tan[e + f*x], x
], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a
*B - b*C, 0]

Rubi steps

\begin {align*} \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx &=\frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(-B c+A d-C d) \int \tan (e+f x) \, dx}{c^2+d^2}+\frac {\left (c^2 C-B c d+A d^2\right ) \int \frac {1+\tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{c^2+d^2}\\ &=\frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {\left (c^2 C-B c d+A d^2\right ) \operatorname {Subst}\left (\int \frac {1}{c+x} \, dx,x,d \tan (e+f x)\right )}{d \left (c^2+d^2\right ) f}\\ &=\frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {\left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right ) f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [C]  time = 0.20, size = 117, normalized size = 1.18 \[ \frac {\frac {2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right )}+\frac {(-i A+B+i C) \log (-\tan (e+f x)+i)}{c+i d}+\frac {(i A+B-i C) \log (\tan (e+f x)+i)}{c-i d}}{2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x]),x]

[Out]

((((-I)*A + B + I*C)*Log[I - Tan[e + f*x]])/(c + I*d) + ((I*A + B - I*C)*Log[I + Tan[e + f*x]])/(c - I*d) + (2
*(c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)))/(2*f)

________________________________________________________________________________________

fricas [A]  time = 1.18, size = 118, normalized size = 1.19 \[ \frac {2 \, {\left ({\left (A - C\right )} c d + B d^{2}\right )} f x + {\left (C c^{2} - B c d + A d^{2}\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (C c^{2} + C d^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \, {\left (c^{2} d + d^{3}\right )} f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(2*((A - C)*c*d + B*d^2)*f*x + (C*c^2 - B*c*d + A*d^2)*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e) + c^2)
/(tan(f*x + e)^2 + 1)) - (C*c^2 + C*d^2)*log(1/(tan(f*x + e)^2 + 1)))/((c^2*d + d^3)*f)

________________________________________________________________________________________

giac [A]  time = 2.06, size = 109, normalized size = 1.10 \[ \frac {\frac {2 \, {\left (A c - C c + B d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {{\left (B c - A d + C d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {2 \, {\left (C c^{2} - B c d + A d^{2}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d + d^{3}}}{2 \, f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*(A*c - C*c + B*d)*(f*x + e)/(c^2 + d^2) + (B*c - A*d + C*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) + 2*(C*
c^2 - B*c*d + A*d^2)*log(abs(d*tan(f*x + e) + c))/(c^2*d + d^3))/f

________________________________________________________________________________________

maple [B]  time = 0.26, size = 234, normalized size = 2.36 \[ \frac {d \ln \left (c +d \tan \left (f x +e \right )\right ) A}{f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) B c}{f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) c^{2} C}{f \left (c^{2}+d^{2}\right ) d}-\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) A d}{2 f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) B c}{2 f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) C d}{2 f \left (c^{2}+d^{2}\right )}+\frac {A \arctan \left (\tan \left (f x +e \right )\right ) c}{f \left (c^{2}+d^{2}\right )}+\frac {B \arctan \left (\tan \left (f x +e \right )\right ) d}{f \left (c^{2}+d^{2}\right )}-\frac {C \arctan \left (\tan \left (f x +e \right )\right ) c}{f \left (c^{2}+d^{2}\right )} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x)

[Out]

1/f/(c^2+d^2)*d*ln(c+d*tan(f*x+e))*A-1/f/(c^2+d^2)*ln(c+d*tan(f*x+e))*B*c+1/f/(c^2+d^2)/d*ln(c+d*tan(f*x+e))*c
^2*C-1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*A*d+1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*B*c+1/2/f/(c^2+d^2)*ln(1+tan(f*
x+e)^2)*C*d+1/f/(c^2+d^2)*A*arctan(tan(f*x+e))*c+1/f/(c^2+d^2)*B*arctan(tan(f*x+e))*d-1/f/(c^2+d^2)*C*arctan(t
an(f*x+e))*c

________________________________________________________________________________________

maxima [A]  time = 0.55, size = 106, normalized size = 1.07 \[ \frac {\frac {2 \, {\left ({\left (A - C\right )} c + B d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {2 \, {\left (C c^{2} - B c d + A d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d + d^{3}} + \frac {{\left (B c - {\left (A - C\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}}}{2 \, f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(2*((A - C)*c + B*d)*(f*x + e)/(c^2 + d^2) + 2*(C*c^2 - B*c*d + A*d^2)*log(d*tan(f*x + e) + c)/(c^2*d + d^
3) + (B*c - (A - C)*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2))/f

________________________________________________________________________________________

mupad [B]  time = 9.90, size = 109, normalized size = 1.10 \[ \frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (C-A+B\,1{}\mathrm {i}\right )}{2\,f\,\left (d+c\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (B-A\,1{}\mathrm {i}+C\,1{}\mathrm {i}\right )}{2\,f\,\left (c+d\,1{}\mathrm {i}\right )}+\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (C\,c^2-B\,c\,d+A\,d^2\right )}{d\,f\,\left (c^2+d^2\right )} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A + B*tan(e + f*x) + C*tan(e + f*x)^2)/(c + d*tan(e + f*x)),x)

[Out]

(log(tan(e + f*x) + 1i)*(B*1i - A + C))/(2*f*(c*1i + d)) + (log(tan(e + f*x) - 1i)*(B - A*1i + C*1i))/(2*f*(c
+ d*1i)) + (log(c + d*tan(e + f*x))*(A*d^2 + C*c^2 - B*c*d))/(d*f*(c^2 + d^2))

________________________________________________________________________________________

sympy [A]  time = 1.31, size = 984, normalized size = 9.94 \[ \text {result too large to display} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e)),x)

[Out]

Piecewise((zoo*x*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)), ((A*x + B*log(tan(e + f
*x)**2 + 1)/(2*f) - C*x + C*tan(e + f*x)/f)/c, Eq(d, 0)), (-I*A*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*
f) - A*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*A/(-2*d*f*tan(e + f*x) + 2*I*d*f) - B*f*x*tan(e + f*x)/(-2*d*f*
tan(e + f*x) + 2*I*d*f) + I*B*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) + B/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*C*f*
x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - C*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - C*log(tan(e + f*x)**2
 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*C*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d
*f) + I*C/(-2*d*f*tan(e + f*x) + 2*I*d*f), Eq(c, -I*d)), (I*A*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f)
 - A*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + I*A/(-2*d*f*tan(e + f*x) - 2*I*d*f) - B*f*x*tan(e + f*x)/(-2*d*f*ta
n(e + f*x) - 2*I*d*f) - I*B*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + B/(-2*d*f*tan(e + f*x) - 2*I*d*f) + I*C*f*x*
tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - C*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) - C*log(tan(e + f*x)**2 +
 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - I*C*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) - 2*I*d*f
) - I*C/(-2*d*f*tan(e + f*x) - 2*I*d*f), Eq(c, I*d)), (x*(A + B*tan(e) + C*tan(e)**2)/(c + d*tan(e)), Eq(f, 0)
), (2*A*c*d*f*x/(2*c**2*d*f + 2*d**3*f) + 2*A*d**2*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) - A*d**2*lo
g(tan(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f) - 2*B*c*d*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) + B*c
*d*log(tan(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f) + 2*B*d**2*f*x/(2*c**2*d*f + 2*d**3*f) + 2*C*c**2*log(c/d
+ tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) - 2*C*c*d*f*x/(2*c**2*d*f + 2*d**3*f) + C*d**2*log(tan(e + f*x)**2 + 1
)/(2*c**2*d*f + 2*d**3*f), True))

________________________________________________________________________________________